package fr.jade.resources.webapp;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import fr.jade.base.JadeBaseComponent;
import fr.jade.fraclite.api.control.NoSuchAttributeException;
import fr.jade.resources.api.Servlets;

public class ServletsWrapper extends JadeBaseComponent implements Servlets{

  Map<String, String> servletsMapping;
  
  public ServletsWrapper(){
    servletsMapping = new HashMap<String, String>();
  }
  
  @Override
  public Map<String, String> getServletsMapping() {
    return servletsMapping;
  }
  @Override
  public String getAttribute(String name) throws NoSuchAttributeException {
    String value = (String) (servletsMapping.get(name));
    if(value == null){
      throw new NoSuchAttributeException(name);
    }else{
      return value;
    }
  }
  @Override
  public String[] listFcAtt() {
    Set<String> keys = servletsMapping.keySet();
    return (String[]) (keys.toArray(new String[keys.size()]));
  }
  @Override
  public void setAttribute(String name, String value) throws NoSuchAttributeException {
    servletsMapping.put(name, value);
  }

  
}
